<%@ page import="java.util.ArrayList" %>
<%@ page import="com.situ.web.entity.Student" %>
<%@ page import="com.situ.web.vo.StudentBanjiVO" %><%--
  Created by IntelliJ IDEA.
  User: 24186
  Date: 2022-01-28
  Time: 18:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" type="text/css" href="/JavaWeb/static/bootstrap-3.4.1-dist/css/bootstrap.css"/>
</head>
<body>
<%--    <a class="btn btn-primary" href="<%=request.getContextPath()%>/student?method=getStudentInsertPage">insert</a>--%>
    <a class="btn btn-primary" href="<%=request.getContextPath()%>/student_insert.jsp">insert</a>
    <table class="table table-striped table-bordered table-hover table-condensed">
        <tr>
            <td>ID</td>
            <td>Name</td>
            <td>Age</td>
            <td>Gender</td>
            <td>BanJi</td>
            <td>Delete/Edit</td>
        </tr>
<%--        <%%>中可以嵌套java代码--%>
        <%
            ArrayList<StudentBanjiVO> list =
                    (ArrayList<StudentBanjiVO>) request.getAttribute("list");
            for (StudentBanjiVO studentBanjiVO : list) {
        %>
                <tr>
                    <td><%=studentBanjiVO.getStudentId()%></td>
                    <td><%=studentBanjiVO.getStudentName()%></td>
                    <td><%=studentBanjiVO.getStudentAge()%></td>
                    <td><%=studentBanjiVO.getStudentGender()%></td>
                    <td><%=studentBanjiVO.getBanjiName()%></td>
                <%--                    <td><a href="<%=request.getContextPath()%>/student?method=deleteById&id=<%=student.getId()%>"/>delete</td>--%>
                    <td>
                        <a class="btn btn-danger btn-sm" href="javascript:void(0)" onclick="deleteById(<%=studentBanjiVO.getStudentId()%>)">delete</a>
                        <a class="btn btn-warning btn-sm" href="<%=request.getContextPath()%>/student?method=selectById&id=<%=studentBanjiVO.getStudentId()%>">edit</a>
                    </td>
                </tr>
        <%
            }
        %>
    </table>

    <script type="text/javascript">
        function deleteById(id) {
            var isDelete = confirm("你确认要删除吗?");
            if(isDelete){
                location.href = "<%=request.getContextPath()%>/student?method=deleteById&id="+id;
            }
        }
    </script>

<%--    ${list}--%>
</body>
</html>
